import 'package:flutter/material.dart';
import 'package:t_flutter_test/pages/index.dart';
import 'package:t_flutter_test/pages/file_01.dart';
import 'package:t_flutter_test/pages/file_02.dart';
import 'package:t_flutter_test/pages/file_03.dart';
import 'package:t_flutter_test/pages/file_04.dart';
import 'package:t_flutter_test/pages/file_05.dart';
import 'package:t_flutter_test/pages/file_06.dart';
import 'package:t_flutter_test/pages/file_07.dart';
import 'package:t_flutter_test/pages/file_08.dart';
import 'package:t_flutter_test/pages/file_09/index.dart';

class RouterInfo {
  final String path;
  final WidgetBuilder pageBuilder;
  final String name;

  RouterInfo(this.path, this.pageBuilder, this.name);
}

// 所有路由
List<RouterInfo> allRouter = [
  /* 
    IndexPage() 类型是 Widget
    WidgetBuilder的定义: typedef WidgetBuilder = Widget Function(BuildContext context);
    所以 Widget 转 WidgetBuilder 类型 可通过 (context) => IndexPage() 实现
   */
  RouterInfo('/', (context) => IndexPage(), '首页'),
  RouterInfo('/file01', (context) => File01(), '有/无状态组件&生命周期'),
  RouterInfo('/file02', (context) => File02(), 'Container组件'),
  RouterInfo('/file03', (context) => File03(), 'Image组件'),
  RouterInfo('/file04', (context) => File04(), 'Column&Row&Expanded组件'),
  RouterInfo('/file05', (context) => File05(), 'Stack组件'),
  RouterInfo('/file06', (context) => File06(), 'ListView组件'),
  RouterInfo('/file07', (context) => File07(), 'GridView组件'),
  RouterInfo('/file08', (context) => File08(), 'Dio插件'),
  RouterInfo('/file09', (context) => File09(), '智慧商城'),
];

final Map<String, WidgetBuilder> routes = {
  for (RouterInfo route in allRouter) route.path: route.pageBuilder,
};
